namespace Delphi.Mimir.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddRawAnalystEstimates : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "raw.eod_earnings_estimates",
                c => new
                    {
                        aee_id = c.Int(nullable: false, identity: true),
                        aee_sym_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aee_exc_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aee_dt = c.DateTime(nullable: false),
                        aee_period = c.String(nullable: false, maxLength: 25, unicode: false),
                        aee_curt_fg = c.Boolean(nullable: false),
                        aee_avg_estimate = c.Decimal(precision: 18, scale: 6),
                        aee_low_estimate = c.Decimal(precision: 18, scale: 6),
                        aee_high_estimate = c.Decimal(precision: 18, scale: 6),
                        aee_year_ago = c.Decimal(precision: 18, scale: 6),
                        aee_nof_analyst = c.Decimal(precision: 18, scale: 6),
                        aee_next_earnings_dt = c.DateTime(),
                    })
                .PrimaryKey(t => t.aee_id);
            
            CreateTable(
                "raw.eod_earnings_histories",
                c => new
                    {
                        aeh_id = c.Int(nullable: false, identity: true),
                        aeh_sym_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aeh_exc_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aeh_dt = c.DateTime(nullable: false),
                        aeh_eps_est = c.Decimal(precision: 18, scale: 6),
                        aeh_eps_act = c.Decimal(precision: 18, scale: 6),
                        aeh_eps_diff = c.Decimal(precision: 18, scale: 6),
                        aeh_eps_surp = c.Decimal(precision: 18, scale: 6),
                    })
                .PrimaryKey(t => t.aeh_id);
            
            CreateTable(
                "raw.eod_eps_revisions",
                c => new
                    {
                        arv_id = c.Int(nullable: false, identity: true),
                        arv_sym_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        arv_exc_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        arv_dt = c.DateTime(nullable: false),
                        arv_period = c.String(nullable: false, maxLength: 25, unicode: false),
                        arv_curt_fg = c.Boolean(nullable: false),
                        arv_up_7d = c.Int(),
                        arv_up_30d = c.Int(),
                        arv_down_30d = c.Int(),
                        arv_down_90d = c.Int(),
                    })
                .PrimaryKey(t => t.arv_id);
            
            CreateTable(
                "raw.eod_eps_trends",
                c => new
                    {
                        aet_id = c.Int(nullable: false, identity: true),
                        aet_sym_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aet_exc_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aet_dt = c.DateTime(nullable: false),
                        aet_period = c.String(nullable: false, maxLength: 25, unicode: false),
                        aet_curt_fg = c.Boolean(nullable: false),
                        aet_current_est = c.Decimal(precision: 18, scale: 6),
                        aet_est_7d = c.Decimal(precision: 18, scale: 6),
                        aet_est_30d = c.Decimal(precision: 18, scale: 6),
                        aet_est_60d = c.Decimal(precision: 18, scale: 6),
                        aet_est_90d = c.Decimal(precision: 18, scale: 6),
                    })
                .PrimaryKey(t => t.aet_id);
            
            CreateTable(
                "raw.eod_eps_growth_estimates",
                c => new
                    {
                        age_id = c.Int(nullable: false, identity: true),
                        age_sym_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        age_exc_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        age_comp_typ = c.String(nullable: false, maxLength: 25, unicode: false),
                        age_dt = c.DateTime(nullable: false),
                        age_curt_qtr = c.Decimal(precision: 18, scale: 6),
                        age_next_qtr = c.Decimal(precision: 18, scale: 6),
                        age_curt_year = c.Decimal(precision: 18, scale: 6),
                        age_next_year = c.Decimal(precision: 18, scale: 6),
                        age_past_5y = c.Decimal(precision: 18, scale: 6),
                        age_next_5y = c.Decimal(precision: 18, scale: 6),
                        age_pe = c.Decimal(precision: 18, scale: 6),
                        age_peg = c.Decimal(precision: 18, scale: 6),
                    })
                .PrimaryKey(t => t.age_id);
            
            CreateTable(
                "raw.eod_revenue_estimates",
                c => new
                    {
                        aer_id = c.Int(nullable: false, identity: true),
                        aer_sym_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aer_exc_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        aer_dt = c.DateTime(nullable: false),
                        aer_period = c.String(nullable: false, maxLength: 25, unicode: false),
                        aer_curt_fg = c.Boolean(nullable: false),
                        aer_estimate_dt = c.DateTime(nullable: false),
                        aer_avg_estimate = c.Decimal(precision: 18, scale: 6),
                        aer_low_estimate = c.Decimal(precision: 18, scale: 6),
                        aer_high_estimate = c.Decimal(precision: 18, scale: 6),
                        aer_year_ago = c.Decimal(precision: 18, scale: 6),
                        aer_sales_growth = c.Decimal(precision: 18, scale: 6),
                        aer_nof_analyst = c.Int(),
                    })
                .PrimaryKey(t => t.aer_id);
            
        }
        
        public override void Down()
        {
            DropTable("raw.eod_revenue_estimates");
            DropTable("raw.eod_eps_growth_estimates");
            DropTable("raw.eod_eps_trends");
            DropTable("raw.eod_eps_revisions");
            DropTable("raw.eod_earnings_histories");
            DropTable("raw.eod_earnings_estimates");
        }
    }
}
